package com.zbkj.service.dividend.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zbkj.service.dividend.model.DividendPoolRecord;
import com.zbkj.service.dividend.request.DividendPoolRecordRequest;
import org.apache.ibatis.annotations.Param;

import java.math.BigDecimal;
import java.util.List;

/**
 * 用户分红记录 Mapper 接口
 */
public interface DividendPoolRecordMapper extends BaseMapper<DividendPoolRecord> {

    /**
     * 分页查询分红记录
     */
    List<DividendPoolRecord> findPageList(@Param("request") DividendPoolRecordRequest request);

    /**
     * 根据用户ID查询分红记录
     */
    List<DividendPoolRecord> findByUserId(@Param("userId") Integer userId);

    /**
     * 根据订单ID查询分红记录
     */
    DividendPoolRecord findByOrderNo(@Param("orderNo") Integer orderNo);

    /**
     * 统计用户分红总额
     */
    BigDecimal sumDividendByUserId(@Param("userId") Integer userId);

    /**
     * 获取分红统计信息
     */
    List<DividendPoolRecord> getDividendStats(@Param("startDate") String startDate,
                                              @Param("endDate") String endDate);

    /**
     * 批量插入分红记录
     */
    int batchInsert (@Param("records") List<DividendPoolRecord> records);

    /**
     * 插入分红记录
     */
    int insert(@Param("record") DividendPoolRecord record,
               @Param("operator") String operator,
               @Param("operation") String operation);

}